#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://www.oj7.cn/

string s, t;
int dp[107][107];
int m, n;
int main()
{
	while (cin >> s >> t)
	{
		memset(dp, 0, sizeof(dp));
	int a = s.size();
		int b =t.size();
		for (int i = 1; i <=a; i++)
			for (int j = 1; j <=b; j++)
			{
				 if (s[i - 1] == t[j - 1])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
		 	      else
				 dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
			}
		cout << dp[a][b]<<endl;
	}
	return 0;
}
